/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Database;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author Prasetyawan
 */
public class CreateTableDaftarPesan {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
   
String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "hr";
        String password = "hr";

        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi is OK");
            Statement statement = conn.createStatement();
            String sql = " CREATE table daftarpesananbarang ( NAMATOKO varchar2(20) NOT NULL,"
                    + "KODETOKO varchar2(20) NOT NULL,"
                    + "KODEBARANG varchar2(38) NOT NULL,"
                    + "NAMABARANG VARCHAR2(30) NOT NULL,"
                    + "JENIS VARCHAR2(100) NOT NULL,"
                    + "JUMLAH NUMBER(38) NOT NULL,"
                    + "HARGABARANG NUMBER(20) NOT NULL) ";


            statement.executeUpdate(sql);

        } catch (SQLException e) {
            System.out.println("error :" + e.getMessage());
        }
    }
}